home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / neuron.zip / THEORY.DOC < prev    next >
Text File  |  1992-07-06  |  13KB  |  242 lines

  1. E.FARHI         neural networks         THEORY.DOC      06/1992.
  2. ****************************************************************************
  3.                         LET'S NOW SEE HOW IT WORKS
  4. ****************************************************************************
  5.  
  6. I don't intend to write a thesis about it, but here are some important points 
  7. in order to understand network theory.
  8.  
  9. II) AN INTRODUCTION TO NEURAL NETWORKS
  10. **************************************
  11.  
  12. II.1) Where does it come from ?.
  13. -------------------------------
  14.  
  15.         Nature is certainly what's best on earth. So man is trying to imitate 
  16. it. We thought about copying neural systems for computing and electronic 
  17. applications because we were not very satisfied of what a usual computer can do 
  18. (just think about hand-writting recognition and space optimisation problems).
  19.         In man brain, which is composed with billions of neurons, each neuron 
  20. receives some nerve impulses from his dendrites, and emits a pulse through the 
  21. axone. Some neurons are more likely to receive signals (vision, hearing,...) 
  22. and others lead to an action (move, idea,...).
  23.         A formal neural network is just a mathematical model of this.
  24.  
  25. II.2) And now, let me introduce you to the neuron.
  26. --------------------------------------------------
  27.  
  28.         The formal neuron is a tiny little thing, that receives some inputs, 
  29. then computes its synaptic potential, and then emits its state to its friends.
  30.         
  31.                I1 --(W1)--\             'Wi' is the synaptic link (weight).
  32.                 .    .     \            'Ii' is the neuron input
  33.                Ii --(Wi)-->(S)--> A
  34.                 .    .     /
  35.                In --(Wn)--/
  36.  
  37.        Usually we use a linear potential:
  38.                 S=Sum(Ii*Wi)+B
  39.                     where 'B' is a constant for each neuron ('bias').
  40.        The output ('activity') is:
  41.                 A=f(S)
  42.                     where f is either a Heaviside type function or a sigmoid 
  43. type function.
  44.                    ^(A)                              ^(A)
  45.                    |                             (+1)|     _____
  46.                (+1)|--------                         | .--
  47.                    |                                 |/
  48.       -------------+---------->(S)        -----------+--------------->(S)
  49.                    |                                /|
  50.            --------|(-1)                     ____--' |
  51.                    |                                 |(-1)
  52.                 Heaviside                       Sigmoid
  53.  
  54.        You see that there is a high (often +1) and a low (why not -1 ?) state 
  55. for the neuron. In fact the sigmoid curve is linked to a constant called 
  56. 'temperature' by analogy to thermodynamic systems, and the Heaviside case 
  57. corresponds to T=0.
  58.        It is also possible to associate a probability to those curves. In that 
  59. case, the only possible states are high and low (without any middle state such 
  60. as for the sigmoid). You may have guessed (who knows ?) that it is called the 
  61. 'stochastic' model.                  
  62.  
  63. II.3) How the net works...
  64. --------------------------
  65.  
  66.        It would not have been very interessant to stop here. So, with some 
  67. neurons, we build a network. To do that, it is just necessary to define links 
  68. between neurons.
  69.        To simplify, we group neurons into different layers. If neurons of a 
  70. single layer are linked together, it is a 'Hopfield' type layer, else it's a 
  71. 'Preceptron' type layer. The final network is formed of various different 
  72. layers...                                  __________
  73.                                           /          \
  74.        (1) ... (n)                      (1)--(2) ... (n)
  75.       / | \   / | \                      |    |       |
  76.    (1) ... (i) ... (n')
  77.   / | \   / | \    / | \                               
  78.         Preceptron                         Hopfield
  79.  
  80.        If we use more than one Preceptron layer, we obtain a ... 
  81. multi-preceptron network. This structure is often used for hand-writting 
  82. recognition and some expert-systems. The Hopfield structure can learn less 
  83. prototypes, and is a dynamic system, evoluting towards a stable state. It can 
  84. also be used as an auto-associative memory, but isn't very efficient (to tell 
  85. you the truth).
  86.        There are many other types of networks such as: Kohonen networks, 
  87. Boltzmann machines, auto-feedback model, etc...but, don't worry I won't talk 
  88. about them in this doc ! If you really want to know something about them, I 
  89. invite you to read some of the books in the bibliography list.
  90.  
  91. II.4) Let's go to school
  92. ------------------------
  93.  
  94.        If you want to use your network, you need to teach it something nice. 
  95. There are two main algorithms used for learning. A Hopfield network can learn 
  96. directly with the Hebb rule, and a multi-layer learns better with the 
  97. back-propagation rule (an extension of the Widrow-Hoff rule).
  98.        
  99.        Now, let's consider a Hopfield network. You now know that it has just a 
  100. single connected layer (say, 'n' neurons). Suppose you want to teach him to 
  101. memorize a prototype, composed of 'n' data (usually binary data, +1 or -1). In 
  102. that case a prototype is just an input. The output you want to teach to the net 
  103. IS the input. You just make:
  104.                 Wij(t+1)=Wij(t)+m*Pi*Pj         (Hebb rule)
  105.                    where Pi,Pj are the inputs of the prototype associated to 
  106.                      the neurons i and j.
  107.                    m>0 is a constant or, better, the boolean value (i<>j).
  108.        That procedure has to be repeated for each prototype, as long as the 
  109. network hasn't memorized it, that is to say till the prototype isn't 
  110. a stable state for the net (don't forget that such a net has its own dynamics).
  111.        For a Hopfield net, the prototypes can be memorized if they are 
  112. orthogonal together, and the net is stable if Sign(Sum(Wij*Pj))=Sign(Pi).
  113.  
  114.        For a multi-layer network, it's a little more complicated. Basically, we 
  115. set the input of the net, then compute the global state, compare the output to 
  116. the one expected (we are teaching to the net an input-output prototype) then 
  117. reakon for each output neuron a local error. The 'error gradient 
  118. back-propagation' algorithm consists in calculating for each neuron the local 
  119. error from the output towards the input, and changing the synaptic links.
  120.        To apply this method, we need a sigmoid type neuron. In fact we try to 
  121. reduce the quadratic error:
  122.                 QE=Sum((Ai-Oi)^2)/2
  123.                    where Oi is the expected (reference) output.
  124.        Let's consider a net formed with the layers 'i','j' and 'k'.The local 
  125. error for an output neuron is:
  126.                 Ek=(Ak-Ok)*f'(Sk)       'k' index is for the output layer.
  127.                    where f' is the derivative of the sigmoid.
  128.        For an intermediate layer (index 'j') the error is:
  129.                 Ej=Sum(Wjk*Ek)*f'(Sj)
  130.        The link Wij is then modified:
  131.                 Wij=Wij-m*Ej*Ai                 (m>0)
  132.        NB: we have also Wjk=Wjk-a*Ek*Aj. and a similar relation for the bias B.
  133.        Typically, for a three layers net, 'k' is the output, 'i' the input an 
  134. 'j' is a 'hidden' layer.
  135.  
  136.        Anyway for every network, we can define some statistical variables:
  137.                 E=-Sum(Wij*Ai*Aj)/2     Global network energy.
  138.                 W=Sum(Wij)/N            Mean synaptic link.
  139.                 QW=Sum(Wij^2)/N         Quadractic link.
  140.  
  141. II.5) What's up doc ? (this is the most interesting)
  142. ---------------------
  143.  
  144.         All right. Now your network has learned some prototypes. We are going 
  145. to see a few properties of your net.
  146.  
  147. What a net !
  148.         The memorization is performed thanks to the synaptic links. So the 
  149. information isn't localized (such as for a logic computer). You can even 
  150. partially destroy the net without loosing the information ! (but of course if 
  151. you remove too many neurons, the output will have nothing common with what you 
  152. expect). This explains why the human brain looses daily thousands of neurons, 
  153. but you don't feel it untill you're very old !
  154.  
  155. Memorization capacity.
  156.         Anyway, don't be too hopeful, your net has a limited memorization 
  157. capacity. If you make it learn too many things, it may forget everything in a 
  158. big mess ! In fact, the number of prototypes it can memorize depends of the 
  159. number of neurons and links.
  160.         To quantify this, we define
  161.                 alpha=P/C
  162.                    where P is the number of prototypes and
  163.                          C is the mean number of connections by neuron.
  164.         The thermodynamic study shows that for a Hopfield network, there is a 
  165. critical value: alphaC # 0.14 .
  166.           If alpha<alphaC the prototypes are memorized.
  167.           For alpha=alphaC appends a first order transition.
  168.           And if alpha>alphaC the network saturates and forgets everything.
  169.         This study has been done by analogy with a magnetic spin system.
  170.         Usually, a multi-layer network has a critical alpha between 1 and 2, 
  171. and we can avoid the net overflow limiting variations of synaptic links; the 
  172. net then forgets the oldest prototypes progressively.
  173.         So, a Hopfield net can't learn too many things, but a multi-layer one 
  174. is much more efficient.
  175.  
  176. Generalization capacity
  177.         The network knows what you haven't told it ! In fact it can predict and 
  178. extrapolate an output for an input it doesn't know. This is why you can use it 
  179. for caracter recognition. It is called an auto-associative memory.
  180.         It has been shown that the more a net knows its prototypes, the less it 
  181. can generalize, so you have to find a compromise. I usually use a 5 % to 10 % 
  182. error rate.
  183.  
  184. How does it really work ?
  185.         Basically, a Preceptron layer is a classifier. It defines a partition 
  186. of prototypes into 2^n classes limited by hyperplanes into the solutions space. 
  187. Inside the hidden layers, the net builds an internal representation of each 
  188. prototype. Studying those layers shows how the network memorizes and organizes 
  189. its information.
  190.         For a Hopfield layer, it different. The memorized prototypes are in 
  191. fact the mimima of the energy function. That's why we can use such a net for a 
  192. function optimization problems and shapes recognition.
  193.  
  194. II.6) What you can do with it
  195. -----------------------------
  196.  
  197.         Here are some particular applications of neural networks. Of course, 
  198. there are many others...
  199.  
  200. Parity recognition
  201.         We use a three precepton layer network
  202.                 input   8 neurons       from 0 to 255.
  203.                 hidden  8 neurons
  204.                 output  1 neuron        -1=odd,+1=even.
  205.         You teach the right parity for some numbers (for instance 1 to 15) and 
  206. the net will extrapolate for other inputs.
  207.  
  208. Data compression
  209.         If you want to compress pictures or sound, you can use a three 
  210. precepton layer network:
  211.                 input   n1 neurons      a bit of data
  212.                 hidden  n2 neurons      n2<n1 -> compression
  213.                 output  n1 neurons      input=output for learning.
  214.         Inside the hidden layer, a compression (with possibly some losses) is 
  215. performed because n2<n1. To code the picture, for instance, you just need to 
  216. save the internal representation of the hidden layer. To decode the compressed 
  217. image, you set the state of the hidden layer to the saved state.
  218.  
  219. Function optimisation
  220.         Suppose you've got a problem in which you need to find the extrema of a 
  221. function - by example, the traveling salesman problem - you can then use a 
  222. Hopfield network which energy function is the function you are studying. The 
  223. only difficulty is to find the link variations you need to impose.
  224.                 E=-Sum(Wij*Ai*Aj)       global energy.
  225.                 Si=Sum(Wij*Aj)          we assume B=0 here.
  226.                 Ai=f(Si)                f: Heaviside or sigmoid.
  227.         Of course, you know the Hebb rule and your expression of E, function to 
  228. optimize. You need to derivate E to find a condition on Wij. I let you the 
  229. computation...
  230.  
  231. Caracter and shape recognition.
  232.         You can use a Hopfield network, but you'd better try it with a 
  233. multi-layer network (more efficient, better capacity). You just need to teach 
  234. the net different types of digitalized caracters (for instance for a 10*14 
  235. caracter you need 140 input neurons). For the output, you associate a neuron to 
  236. each caracter (for instance 26 neurons for one alphabet). Possibly you can use 
  237. a single layer network (an input and an output).
  238.         It's even better if you process the picture before sending it to the 
  239. net (thinning, removing isolated pixels,...).
  240.  
  241. (next to read: NEURON.DOC and NETWORK.DOC)
  242.